package com.pei.controller;

import com.pei.pojo.Product;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
public class ProductController {
    @RequestMapping("/getProducts")
    public void getProducts(String[] proIds){
        for(String s : proIds){
            System.out.println(s);
        }
    }
    @RequestMapping("/getProductsList")
    public void getProductsList(@RequestParam("proIds") List<String> proIds){
        for(String s : proIds){
            System.out.println(s);
        }
    }

    @RequestMapping("/getProduct")
    public void getProduct(@RequestBody Product product){
        String proId = product.getProId();
        String proName = product.getProName();
        System.out.println("获取到了id为"+proId+"名称为"+proName);
    }
    @RequestMapping("/getProductList")
    public void getProduct(@RequestBody List<Product> products){
        for(Product p :products){
            String proId = p.getProId();
            String proName = p.getProName();
            System.out.println("获取到了id为"+proId+"名称为"+proName);
        }

    }
}
